package Regex
{
    import TextFile.TextFile;
    
    import mx.collections.ArrayCollection;
    
    public class RegexFile extends TextFile
    {
        private static const REGEX_CHARSET:String = "latin1";
        private var _regexes:ArrayCollection = new ArrayCollection;
        
        public function RegexFile(path:String) {
            super( path, REGEX_CHARSET );
            
            var rows:Array = this.Text.split( "\r" );
            var re:RegExp = new RegExp(/'(.*?[^\\])'.*?[^\\]'(.*?[^\\]?)'.*?[^\\]'(.*?[^\\])'.*?'(.*?)'/);
            var o:Object;
//            var i:int = 0;
            for each(var row:String in rows) {
                o = re.exec(row);
                if(o != null && o.length >= 2) {
//                   if(o[3] == undefined) {
//                       o[3] = "";
//                   }
//                   if(o[4] == undefined) {
//                       o[4] = "";
//                   }
//                    o["index"] = ++i;
                    this._regexes.addItem(new Regex(o[1], o[4], o[2], o[3]));
//                RegexCollection.addItem(new Regex(o[1], o[4], o[2], o[3]));
                }
            }
        }
        
        public function get Regexes():ArrayCollection {
            return _regexes;
        }
    }
}